import { createI18n } from 'vue-i18n'
import en from '../locales/en.json'
import zhCN from '../locales/zh-CN.json'

// ElementPlus 语言包
import enLocale from 'element-plus/es/locale/lang/en'
import zhCnLocale from 'element-plus/es/locale/lang/zh-cn'

const messages = {
  en: {
    ...en,
    ...enLocale
  },
  'zh-CN': {
    ...zhCN,
    ...zhCnLocale
  }
}

const i18n = createI18n({
  legacy: false,
  locale: localStorage.getItem('locale') || 'zh-CN',
  fallbackLocale: 'en',
  messages
})

export default i18n
